namespace KPIS.GERP.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class update0137 : DbMigration
    {
        public override void Up()
        {
            DropForeignKey("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", "dbo.hrm_ps_time_attendants");
            DropIndex("dbo.hrm_ps_absence", new[] { "PsTimeAttendance_WorkingId" });
            CreateTable(
                "dbo.hrm_ps_time_attendance_summary",
                c => new
                    {
                        tas_seq = c.Int(nullable: false, identity: true),
                        emp_seq = c.Int(),
                        cal_for_date = c.DateTime(),
                        working_start = c.Time(),
                        working_end = c.Time(),
                        remarks = c.String(),
                        re_calculate_when = c.DateTime(),
                        record_status = c.String(),
                        created_by = c.Int(),
                        created_when = c.DateTime(),
                        updated_by = c.Int(),
                        updated_when = c.DateTime(),
                        cal_lastest_success = c.Boolean(),
                        cal_lastest_when = c.DateTime(),
                        cal_lastest_remarks = c.String(),
                        cal_atten_morning = c.Boolean(),
                        cal_atten_morning_late = c.Boolean(),
                        cal_getoff_morning = c.Boolean(),
                        cal_getoff_morning_early = c.Boolean(),
                        cal_atten_afternoon = c.Boolean(),
                        cal_atten_afternoon_late = c.Boolean(),
                        cal_getoff_afternoon_early = c.Boolean(),
                        cal_start_working_time = c.Time(),
                        cal_end_working_time = c.Time(),
                        cal_start_working_time_afternoon = c.Time(),
                        cal_end_working_time_morning = c.Time(),
                        cal_is_atten = c.Boolean(nullable: false),
                        cal_is_late = c.Boolean(),
                        cal_is_absence_available = c.Boolean(),
                        cal_is_getoff_early = c.Boolean(),
                        cal_cant_calculate = c.Boolean(nullable: false),
                        cal_reasons_of_cant_calculate = c.String(),
                        cal_absence_id = c.Int(),
                        cal_absence_afternoon_id = c.Int(),
                        working_seq = c.Int(),
                    })
                .PrimaryKey(t => t.tas_seq)
                .ForeignKey("dbo.hrm_ps_employees", t => t.emp_seq)
                .ForeignKey("dbo.hrm_ps_absence", t => t.cal_absence_id)
                .ForeignKey("dbo.hrm_ps_absence", t => t.cal_absence_afternoon_id)
                .ForeignKey("dbo.hrm_ps_time_attendants", t => t.working_seq)
                .Index(t => t.emp_seq)
                .Index(t => t.cal_absence_id)
                .Index(t => t.cal_absence_afternoon_id)
                .Index(t => t.working_seq);
            
            AddColumn("dbo.hrm_ps_time_attendants", "working_status", c => c.String());
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_success");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_when");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_lastest_remarks");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_getoff_afternoon_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time_afternoon");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time_morning");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_atten");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_late");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_absence_available");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_is_getoff_early");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_cant_calculate");
            DropColumn("dbo.hrm_ps_time_attendants", "cal_reasons_of_cant_calculate");
            DropColumn("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId");
        }
        
        public override void Down()
        {
            AddColumn("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", c => c.Int());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_reasons_of_cant_calculate", c => c.String());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_cant_calculate", c => c.Boolean(nullable: false));
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_getoff_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_absence_available", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_is_atten", c => c.Boolean(nullable: false));
            AddColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time_morning", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time_afternoon", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_end_working_time", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_start_working_time", c => c.Time());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_afternoon_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_afternoon", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning_early", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_getoff_morning", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning_late", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_atten_morning", c => c.Boolean());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_remarks", c => c.String());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_when", c => c.DateTime());
            AddColumn("dbo.hrm_ps_time_attendants", "cal_lastest_success", c => c.Boolean());
            DropIndex("dbo.hrm_ps_time_attendance_summary", new[] { "working_seq" });
            DropIndex("dbo.hrm_ps_time_attendance_summary", new[] { "cal_absence_afternoon_id" });
            DropIndex("dbo.hrm_ps_time_attendance_summary", new[] { "cal_absence_id" });
            DropIndex("dbo.hrm_ps_time_attendance_summary", new[] { "emp_seq" });
            DropForeignKey("dbo.hrm_ps_time_attendance_summary", "working_seq", "dbo.hrm_ps_time_attendants");
            DropForeignKey("dbo.hrm_ps_time_attendance_summary", "cal_absence_afternoon_id", "dbo.hrm_ps_absence");
            DropForeignKey("dbo.hrm_ps_time_attendance_summary", "cal_absence_id", "dbo.hrm_ps_absence");
            DropForeignKey("dbo.hrm_ps_time_attendance_summary", "emp_seq", "dbo.hrm_ps_employees");
            DropColumn("dbo.hrm_ps_time_attendants", "working_status");
            DropTable("dbo.hrm_ps_time_attendance_summary");
            CreateIndex("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId");
            AddForeignKey("dbo.hrm_ps_absence", "PsTimeAttendance_WorkingId", "dbo.hrm_ps_time_attendants", "working_seq");
        }
    }
}
